﻿CREATE TABLE [dbo].[Contact] (
    [ContactId]         UNIQUEIDENTIFIER NOT NULL,
    [OriginatingLeadId] UNIQUEIDENTIFIER NULL,
    [JobTitle]          NVARCHAR (100)   NULL,
    [FirstName]         NVARCHAR (50)    NULL,
    [Department]        NVARCHAR (100)   NULL,
    [NickName]          NVARCHAR (50)    NULL,
    [MiddleName]        NVARCHAR (50)    NULL,
    [LastName]          NVARCHAR (50)    NULL,
    [Suffix]            NVARCHAR (10)    NULL,
    [FullName]          NVARCHAR (160)   NULL,
    [Anniversary]       DATETIME         NULL,
    [BirthDate]         DATETIME         NULL,
    [Description]       NVARCHAR (MAX)   NULL,
    [EmployeeId]        NVARCHAR (50)    NULL,
    [GenderCode]        INT              NULL,
    [AnnualIncome]      MONEY            NULL,
    [HasChildrenCode]   INT              NULL,
    [EducationCode]     INT              NULL,
    [WebSiteUrl]        NVARCHAR (200)   NULL,
    [FamilyStatusCode]  INT              NULL,
    [SpousesName]       NVARCHAR (100)   NULL,
    [EMailAddress1]     NVARCHAR (100)   NULL,
    [EMailAddress2]     NVARCHAR (100)   NULL,
    [EMailAddress3]     NVARCHAR (100)   NULL,
    [AssistantName]     NVARCHAR (100)   NULL,
    [AssistantPhone]    NVARCHAR (50)    NULL,
    [ManagerName]       NVARCHAR (100)   NULL,
    [ManangerPhone]     NVARCHAR (50)    NULL,
    [AccountRoleCode]   INT              NULL,
    [CreatedOn]         DATETIME         NULL,
    [CreatedById]       UNIQUEIDENTIFIER NULL,
    [ModifiedOn]        DATETIME         NULL,
    [ModifiedById]      UNIQUEIDENTIFIER NULL,
    [NumberOfChildren]  INT              NULL,
    [VersionNumber]     ROWVERSION       NULL,
    [MobilePhone]       NVARCHAR (50)    NULL,
    [Telephone1]        NVARCHAR (50)    NULL,
    [Telephone2]        NVARCHAR (50)    NULL,
    [Telephone3]        NVARCHAR (50)    NULL,
    [Fax]               NVARCHAR (50)    NULL,
    [StatusCode]        INT              NULL,
    [OwnerId]           UNIQUEIDENTIFIER NOT NULL,
    [ParentCustomerId]  UNIQUEIDENTIFIER NULL,
    [IsDeleted]         BIT              CONSTRAINT [DF_Contact_IsDeleted] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Contact] PRIMARY KEY CLUSTERED ([ContactId] ASC),
    CONSTRAINT [FK_Contact_Lead] FOREIGN KEY ([OriginatingLeadId]) REFERENCES [dbo].[Lead] ([LeadId]),
    CONSTRAINT [FK_Contact_User] FOREIGN KEY ([OwnerId]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Contact_User_CreatedBy] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_Contact_User_ModifiedBy] FOREIGN KEY ([ModifiedById]) REFERENCES [dbo].[User] ([UserId])
);

